package com.niit.session17;
//如果要对一个实体类的对象进行排序就需要让这个类实现Comparable接口，
//并重写compareTo方法，在里面顶一个好排序的规则
public class Student implements Comparable<Student>{
	private String name;
	private int age;
	
	@Override
	public int compareTo(Student o) {
		if(o.getAge() < age) {
			return 1;
		}else if (o.getAge() > age) {
			return -1;
		}else {
			return 0;
		}
	}
	
	
	
	public Student(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}
	public Student() {
		super();
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	@Override
	public String toString() {
		return "Student [name=" + name + ", age=" + age + "]";
	}


}
